new Vue({
  el: "#app",
  data: {
    tabActive: 1,
    pageNum: 1, //页码
    pageSize: 10, // 每页展示条数
    subType: "1",
    listData: [],

    loginType: 1,
    branchType: 0,
    showTeam: false,
    isEmpty: true,
    loading: true,
  },
  created() {
    setTimeout(() => {
      this.loading = false
      var element = document.querySelector(".mainBox")
      element.classList.add("show")
    }, 500)

    getEruda()
    this.getType()
    this.changeSubType()
    window.getPosterMessageListResult = this.getPosterMessageListResult
    window.getTokenResult = this.getTokenResult
  },
  mounted() {
    appHiddenNav("3")
    // getToken()
    // appHiddenNav("0")
  },
  methods: {
    /** 
            state: 0-失败  1-成功
            res:成功时为 临时token, 失败时为错误信息
      **/
    getTokenResult(state, res) {
      console.log("getTokenResult返回state：", state)
      console.log("getTokenResult返回res：", res)
    },
    getType() {
      var u = window.navigator.userAgent
      console.log("u----", u)
      var loginType1 = u.indexOf("loginType=1") > -1,
        loginType0 = u.indexOf("loginType=0") > -1
      if (loginType1) {
        this.loginType = 1
      } else if (loginType0) {
        this.loginType = 0
      }
      var branchType = u.indexOf("branchType=4") > -1
      if (branchType) {
        this.branchType = 4
      }
      var showTeam = u.indexOf("showTeam=true") > -1
      if (showTeam) {
        this.showTeam = true
      }
    },

    doOpenWebPage: function (name) {
      var link = webLink[name]
      console.log("跳转链接：", link)
      openWebPage(link, 0)
    },
    //图片助手tab 切换
    changeSubType() {
      console.log(this.subType)
      var arr = []
      if (this.subType == "1") {
        getPosterMessageList(1, 2, "person")
      } else if (this.subType == "2") {
        getPosterMessageList(1, 2, "team")
      } else if (this.subType == "4") {
        arr = ["./img/service/company/1.jpg", "./img/service/company/2.png"]
      }

      this.listData = arr
      // console.log("listData", this.listData)
      // getPosterMessageList(this.pageNum, this.pageSize, this.subType)
    },
    getPosterMessageListResult(res) {
    console.log(res)
      var arr = JSON.parse(res)
      if (arr.length > 0) {
        this.isEmpty = false
        this.listData = arr
      } else {
        this.isEmpty = true
        this.listData = [
          "./img/service/default1.jpg",
          "./img/service/default2.jpg",
        ]
      }
    },
    //图片放大
    doShowPicture(link) {
      console.log("图片地址：", link)
      showPicture(link)
    },
    //小程序跳转
    doWxMiniProgram(name) {
      openMiniProgram(name)
    },
    goPicList() {
      if (this.isEmpty) return
      //window.location.href = "./picList.html?subType=" + this.subType
      openWebPage("file:///android_asset/aeonsearvice/picList.html?subType=" + this.subType)
    },
    doCompany(index) {
      //window.location.href = "./companyList.html?type=" + index
       openWebPage("file:///android_asset/aeonsearvice/companyList.html?type=" + index)
    },
    doRefuse() {
      this.$dialog.alert({
        title: "提示",
        message: "该功能还未开发，敬请期待。",
      })
    },
  },
})
